﻿/****************************************************************
  Author:  Ievgenii Nazaruk, ievgenii.nazaruk@gmail.com 
 License:  Microsoft Public License (Ms-PL)
          ( http://www.opensource.org/licenses/ms-pl.html or
            http://www.microsoft.com/opensource/licenses.mspx )
*****************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace WebLayer
{
    public enum Language
    {
        English     = 1,
        Polish      = 2,
        Russian     = 3,
        Ukrainian   = 4
    }

    public class LanguagePage: WebPage 
    {
        public CookieContainer Cookies = null;

        public LanguagePage() :
            this(Language.English)
        { }

        public LanguagePage(Language lang):
            base("LanguagePage", GetLanguagePageUri(lang))
        {
            this.Language = lang;
        }

        public static Uri GetLanguagePageUri(Language language)
        {
            string pageUriTemplate = @"http://sz.speak-up.com.ua/StrefaSluchacza/index.php?lang&id={0}";
            string pageUri = String.Format(pageUriTemplate, (int)language);
            return new Uri(pageUri);
        }


        public Language m_langugage = Language.English;
        public Language Language
        {
            set
            {
                m_langugage = value;
                PageUri = GetLanguagePageUri(value);
            }
            get
            {
                return m_langugage;
            }
        }

        protected override void OnRequest(System.Net.HttpWebRequest request)
        {
            base.OnRequest(request);
            request.CookieContainer = Cookies;
        }
    }
}
